package com.xqls.dal.dao.mybatis;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xqls.dal.dao.FlowMeterDao;
import com.xqls.dal.model.FlowMeter;
import com.xqls.dal.model.FlowMeterExample;
import com.xqls.dal.service.FlowMeterMapper;

@Repository
public class FlowMeterDaoImpl  implements FlowMeterDao {
	@Autowired private FlowMeterMapper mapper;

	@Override
	public List<Map<String, Object>> getAllmap(Map<String, Object> map) {
		return mapper.selectByMap(map);
	}

	@Override
	public boolean addFlow(FlowMeter flowMeter) {
		return mapper.insertSelective(flowMeter)>0;
	}

	@Override
	public boolean deleteFlow(FlowMeter flowMeter){
		return mapper.deleteByflowmeter(flowMeter)>0;
	}

	@Override
	public List<FlowMeter> selectByExample(FlowMeterExample example) {
		return mapper.selectByExample(example);
	}

	@Override
	public FlowMeter selectByKey(Integer key) {
		return mapper.selectByPrimaryKey(key);
	}

	@Override
	public boolean deleteList(List<Integer> keys){
		FlowMeterExample flowMeterExample=new FlowMeterExample();
		flowMeterExample.createCriteria().andFlowIdIn(keys);
		return mapper.deleteByExample(flowMeterExample)>0;
	}

	@Override
	public boolean Update(FlowMeter flowMeter) {
		 return mapper.updateByPrimaryKeySelective(flowMeter)>0;
	}

	@Override
	public List<FlowMeter> queryByExample(FlowMeterExample example){
		return mapper.selectByExample(example);
	}

	@Override
	public FlowMeter selectByClose(String close,String deviceNo) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("closeMonth", close);
		map.put("deviceNo",deviceNo);
		return mapper.selectByClose(map);
	}

	@Override
	public List<FlowMeter> selectBySmonth(Date close, String deviceNo) {
		return mapper.selectBySmonth(close, deviceNo);
	}

	@Override
	public List<Map<String, Object>> selectBySmonth(Map<String, Object> map){
		return mapper.selectBySmonth(map);
	}

	@Override
	public List<Map<String, Object>> selectflowcost(Integer companyId, String closeMonth){
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("companyId", companyId);
		map.put("closeMonth", closeMonth);
		List<Map<String, Object>> list = mapper.selectflowcost(map);
		return list;
	}

	@Override
	public List<Map<String, Object>> getListByMap(Map<String, Object> map) {
		return this.mapper.getListByMap(map);
	}

	@Override
	public FlowMeter selectByTime(String close, String deviceNo) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("closeMonth", close);
		map.put("deviceNo",deviceNo);
		return mapper.selectBytime(map);
	}
}
